import controller.BusController;
import controller.UserController;
import entity.UserEntity;
import frontEnd.Web;

import java.util.Scanner;

/**
 * @author HuangJH
 * @create 2023-11-29-20:17
 */
public class Application {

    /**
     * 主方法
     * @param args
     */
    public static void main(String[] args) {
        try {
            Scanner scanner = new Scanner(System.in);
            System.out.println("欢迎访问班车预约系统");
            UserController userController = new UserController();
            while (true) {
                System.out.println("==========================================");
                System.out.println("1：登录");
                System.out.println("2：注册");
                System.out.print("请输入您的选择：");
                // 如果输入不是1或2就重新输入
                int loginOrRegisterNum = scanner.nextInt();
                System.out.println();
                switch (loginOrRegisterNum) {
                    case 1:
                        // 登录逻辑
                        UserEntity login = userController.login();
                        if(login == null) {
                            break;
                        }
                        BusController busController = new BusController();
                        busController.afterLogin(login);
                        break;
                    case 2:
                        // 注册逻辑
                        userController.register();
                        break;
                    default:
                        // 错误逻辑
                        Web.printfError(loginOrRegisterNum);
                        continue;
                }
            }
        } catch (Exception e) {
            System.out.println("系统异常");
            e.printStackTrace();
        }


    }


}
